from random import random, randint

import pygame

def random_rect(screen, diameter, color=(255,0,0), type=0 ):
    '''
    随机在screen上产生一个图形
    :param screen:
    :param diameter:
    :param color:
    :param type: 0:circle 1:square
    :return:
    '''
    screen_rect = screen.get_rect()
    winx= screen_rect[2]
    winy = screen_rect[3]
    x=randint(0,winx)
    y=randint(0,winy)
    if type == 1: # rect
        pygame.draw.rect(screen,color,(x,y,diameter,diameter))
    else:
        pygame.draw.circle(screen,color,(x,y),diameter/2)



